package com.heima.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.heima.common.PageResult;
import com.heima.pojo.VmType;
import com.heima.mapper.VmTypeMapper;
import com.heima.pojo.vo.VmTypeVo;
import com.heima.service.IVmTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 售货机类型表 服务实现类
 * </p>
 *
 * @author xjy
 * @since 2024-06-06
 */
@Service
public class VmTypeServiceImpl extends ServiceImpl<VmTypeMapper, VmType> implements IVmTypeService {

    /**
     * 分页查询售货机类型
     *
     * @param name 类型名称
     * @return
     */
    @Override
    public PageResult<VmTypeVo> search(PageResult<VmTypeVo> pageResult, String name) {
        LambdaQueryWrapper<VmType> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(name != null, VmType::getName, name);
        Page<VmType> page = page(new Page<>(pageResult.getPageIndex(), pageResult.getPageSize()), queryWrapper);
        return pageResult.of(page, VmTypeVo.class);
    }
}
